package org.xp.judgeplatform.pojo.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
@TableName("submissions")
public class Submission {
    @TableId(type = IdType.AUTO)
    private Long id;
    
    @TableField("problem_id")
    private Long problemId;

    @TableField("user_id")
    private Integer userId;

    private String code;
    private String language;

    /**
     * 判题状态
     * PENDING: 等待判题
     * JUDGING: 判题中
     * AC: 通过
     * WA: 答案错误
     * TLE: 超时
     * MLE: 内存超限
     * RE: 运行错误
     * CE: 编译错误
     * SE: 系统错误
     */
    @TableField("`status`")
    private String status;

    private Integer score;

    @TableField("total_score")
    private Integer totalScore;

    @TableField("passed_cases")
    private Integer passedCases;

    @TableField("total_cases")
    private Integer totalCases;

    @TableField("execution_time")
    private BigDecimal executionTime;  // 秒

    @TableField("memory_usage")
    private BigDecimal memoryUsage;    // MB

    @TableField("error_message")
    private String errorMessage;

    @TableField("judge_result")
    private String judgeResult;        // JSON格式存储详细结果

    @TableField(value = "created_at", insertStrategy = FieldStrategy.NEVER)
    private LocalDateTime createdAt;

    @TableField("judged_at")
    private LocalDateTime judgedAt;
}
